export default {
  addCart(context, payload) {
    return new Promise((resolve, reject) => {
      let oldPrice = context.state.cartList.find(item => item.iid === payload.iid)
      if (oldPrice) {
        context.commit('addCounter', oldPrice)
        resolve('当前商品数量+1')
      } else {
        payload.count = 1
        //context.state.cartList.push(payload)
        context.commit('addToCart', payload)
        resolve('已添加至购物车')
      }
    })
  },
  removeCart(context, payload) {
    return new Promise((resolve, reject) => {
      let oldPrice = context.state.cartList.find(item => item.iid === payload.iid)
        context.commit('removeCounter', oldPrice)
        resolve('当前的商品数量-1')
    })
  },
}